/* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
   Module Name          : com.yaodian100.ec.search.entity.SearchHistory
   Module Description   :

   Date Created      : 2010/8/26
   Original Author   : cut7man
   Team              : yaodian100
   ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
   MODIFICATION HISTORY
   ------------------------------------------------------------------------------
   Date Modified       Modified by       Comments
   ------------------------------------------------------------------------------
   ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
package com.yaodian100.ec.search.entity;

import java.util.Date;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.OrderBy;
import javax.persistence.Table;

import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.LazyCollection;
import org.hibernate.annotations.LazyCollectionOption;

/**
 * @author Andy.Chuang
 * 
 */
@Entity
@Table(name = "EC_SEARCH_HISTORY")
public class SearchHistory {
	private String id;
	private String keyword;
	private Date createDate;
	private List<SearchHistoryItem> searchItems;

	/**
	 * @return the searchItems
	 */
	@OneToMany(mappedBy = "searchHistory", cascade = { CascadeType.ALL })
	@LazyCollection(LazyCollectionOption.FALSE)
	@OrderBy("createDate desc")
	public List<SearchHistoryItem> getSearchItems() {
		return searchItems;
	}

	/**
	 * @param searchItems the searchItems to set
	 */
	public void setSearchItems(List<SearchHistoryItem> searchItems) {
		this.searchItems = searchItems;
	}

	/**
	 * @return the createDate
	 */
	@Column(name = "CREATE_DATE")
	public Date getCreateDate() {
		return createDate;
	}

	/**
	 * @param createDate the createDate to set
	 */
	public void setCreateDate(Date createDate) {
		this.createDate = createDate;
	}

	/**
	 * @return the id
	 */
	@Id
	@GeneratedValue(generator = "assigned")
	@GenericGenerator(name = "assigned", strategy = "assigned")
	@Column(name = "HISTORY_ID", length = 36)
	public String getId() {
		return id;
	}

	/**
	 * @param id the id to set
	 */
	public void setId(String id) {
		this.id = id;
	}

	/**
	 * @return the keyword
	 */
	@Column(length = 255, name = "KEYWORD")
	public String getKeyword() {
		return keyword;
	}

	/**
	 * @param keyword the keyword to set
	 */
	public void setKeyword(String keyword) {
		this.keyword = keyword;
	}

}
